// https://leetcode.cn/problems/reverse-string-ii/description/

func reverse(s string) string {
	ans := ""
	for i := len(s) - 1; i >= 0; i-- {
		ans += sting(s[i])
	}
	return ans
}

func reverseStr(s string, k int) string {
	ans := ""
	for i := 0; i < len(s); i += 2 * k {
		start := i
		end := min(len(s), start + 2 * k)
		remain := end - start
		if remain < k {
			ans += reverse(s[start:end])
		} else {
			ans += reverse(s[start:start + k]) + s[start + k: end]
		}
	}
	return ans
}
